<?
class scores_model extends MY_Model
{
	function __construct()
	{
		parent::__construct();	
		$this->essense = 'scores';		
	}

	function getList($userId)
	{
		$this->db->where('tUser', $userId);
		$res = $this->db->get('scores_ege_abiturient')->result();
		$res = setKeys($res, 'id');

		$abiturIds = extractFieldFromDataArray($res ,'tExam');
		$this->db->where_in('id', $abiturIds);
		$exams = $this->db->get('exams_ege')->result();
		$exams = setKeys($exams, 'id');

		foreach ($res as $itemExam)
		{
			if (isset($exams[$itemExam->tExam]))
				$res[$itemExam->id]->disc = $exams[$itemExam->tExam]->subj;
		}

		return $res;
	}

}